#include "SMG.h"

unsigned char table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00,0x40,0x63,0x39};	//共阴极数码管显示段码(0-F)
unsigned char sce_bit[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char table_real[8]={0};
unsigned char j=0;
unsigned char Point_Num;
void SMG_Time_Interrupt_Init(void)
{
      EA=0;
      TMOD=0x01;
	    TH0=(65536-500)/256;
	    TL0=(65536-500)%256;
	    ET0=1;
	    TR0=1;
      EA=1;

}

void SMG_Show(void) interrupt 1
{

    TH0=(65536-500)/256;  //重载定时器
		TL0=(65536-500)%256;
		
		OE=1;
		
		if(j==Point_Num)
		{
			P0=table[table_real[j]]+0x80;
		}
		else
		{
			P0=table[table_real[j]];
		}
		
		D_selection=1;
		D_selection=0;

		P0=sce_bit[j];
		W_selection=1;
		W_selection=0;
		
		OE=0;
		
		j++;

		if(j>=8) j=0;
}

void SMG_Show_Set(unsigned char Set_table[8],unsigned char Point_Numx)
{
	unsigned char i;
  for(i=0;i<8;i++)
	table_real[i]=Set_table[i];
	Point_Num=Point_Numx;

}
